package com.sky.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.sky.vo.EmployeeVO;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Employee implements Serializable, Cloneable {

    private static final long serialVersionUID = 1L;

    private Long id;


    private String username;

    private String name;

    private String password;

    private String phone;

    private String sex;

    private String idNumber;

    private Integer status;


    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;

    private Long createUser;

    private Long updateUser;

    /**
     * 原型设计模式:
     *  使用场景：对象的深克隆
     *  实现步骤:
     *      1. 类实现Cloneable
     *      2. 重写clone方法然后在内部实现对象的克隆
     * @return
     * @throws CloneNotSupportedException
     */
    @Override
    public EmployeeVO clone() throws CloneNotSupportedException {
        EmployeeVO vo = new EmployeeVO();
        BeanUtils.copyProperties(this, vo);
        return vo;
    }
}
